package cate.game.play.vo;

import cate.common.table.item.hero.row.HeroBaseRow;
import cate.game.play.support.PlayBuildContext;
import cate.game.role.bag.hero.Hero;
import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteField;

/**
 * 英雄简要数据 只保留前段需要观察
 */
public class HeroVO {

	@NoteField(value = "唯一id")
	public String uid;

	@NoteField("英雄id")
	public int tid;

	@NoteField("等级")
	public int level;

	@NoteField("共享等级")
	public int shareLevel;

	@NoteField("英雄阶数")
	public int grade;

	@NoteField("共享阶数")
	public int shareGrade;


	public HeroVO read(Hero hero) {
		if (hero != null) {
			this.uid = hero.uid;
			this.tid = hero.tid;
			this.level = hero.level;
			this.shareLevel = hero.shareLevel;
			this.grade = hero.grade;
			this.shareGrade = hero.shareGrade;
		}
		return this;
	}

	public Hero toHero() {
		Hero hero = new Hero();
		hero.initialize(null);
		hero.uid = uid;
		hero.tid = tid;
		hero.level = level;
		hero.shareLevel = shareLevel;
		hero.grade = grade;
		hero.shareGrade = shareGrade;
		return hero;
	}

	@JsonIgnore
	public HeroBaseRow getTpl(PlayBuildContext ctx) {
		return ctx.heroExcel().base.get(this.tid);
	}

	public HeroVO copy() {
		HeroVO cp = new HeroVO();
		cp.uid = this.uid;
		cp.tid = this.tid;
		cp.level = this.level;
		cp.shareLevel = this.shareLevel;
		cp.grade = this.grade;
		cp.shareGrade = this.shareGrade;
		return cp;
	}
}
